Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[Pytanie] Jak dać komuś skina - non-premium?


Ziela

Rekomendowane odpowiedzi

Opublikowano

Cześć. Mam takie pytanko. Jeśli osoba ma non-premium to czy da się dać tej osobie skina poprzez jakiś plugin, luncher czy coś? Jak tak to jak to zrobić?

Opublikowano

Jest możliwość, ale lepszym rozwiązaniem jest znalezienie sobie skina z listy osób które mają premki i być może mają podobną nazwe jak twoja.

Podaj tu jaki chciał byś mieć nick, a ja zobacze czy są pokrewne.

Opublikowano

Chcę zrobić serwer RP (Realne życie) wątpię, że będzie nick jak np. John_Jenkins czy coś podobnego. - Napiszesz wtedy jak to zrobić?

Opublikowano

public class SkinChangeManager {
	private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
	private static final int WORKER_THREADS = 4;
	private ProtocolManager protocolManager;
	private ConcurrentMap<String, String> skinNames = Maps.newConcurrentMap();
	private ConcurrentMap<String, String> displayNames = Maps.newConcurrentMap();
	private Cache<String, String> profileCache = CacheBuilder.newBuilder().maximumSize(500).expireAfterWrite(4L, TimeUnit.HOURS).build(new CacheLoader() {
		public String load(String name) throws Exception {
			return SkinChangeManager.this.getProfileJson(name);
		}
	});

	public SkinChangeManager(Plugin plugin) {
		this.protocolManager = ProtocolLibrary.getProtocolManager();
		this.protocolManager.getAsynchronousManager().registerAsyncHandler(new PacketAdapter(plugin, ListenerPriority.NORMAL, new PacketType[] {

		PacketType.Play.Server.NAMED_ENTITY_SPAWN,

		PacketType.Play.Server.ENTITY_EFFECT, PacketType.Play.Server.ENTITY_EQUIPMENT, PacketType.Play.Server.ENTITY_METADATA, PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ATTACH_ENTITY, PacketType.Play.Server.BED }) {
			public void onPacketSending(PacketEvent event) {
				if (event.getPacketType() != PacketType.Play.Server.NAMED_ENTITY_SPAWN) {
					return;
				}
				Player toDisplay = (Player) event.getPacket().getEntityModifier(event).read(0);
				String skinName = (String) SkinChangeManager.this.skinNames.get(toDisplay.getName());
				String displayName = (String) SkinChangeManager.this.displayNames.get(toDisplay.getName());
				if ((skinName == null) && (displayName == null)) {
					return;
				}
				StructureModifier<WrappedGameProfile> profiles = event.getPacket().getGameProfiles();
				WrappedGameProfile original = (WrappedGameProfile) profiles.read(0);
				WrappedGameProfile result = new WrappedGameProfile(SkinChangeManager.this.extractUUID(original.getName()), displayName != null ? displayName : original.getName());

				SkinChangeManager.this.updateSkin(result, skinName != null ? skinName : result.getName());
				profiles.write(0, result);
			}
		}).start(4);
	}

	private UUID extractUUID(String playerName) {
		return Bukkit.getOfflinePlayer(playerName).getUniqueId();
	}

	private String getProfileJson(String name) throws IOException {
		URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + extractUUID(name).toString().replace("-", ""));
		final URLConnection uc = url.openConnection();

		CharStreams.toString(new InputSupplier() {
			public InputStreamReader getInput() throws IOException {
				return new InputStreamReader(uc.getInputStream(), Charsets.UTF_8);
			}
		});
	}

	private void updateSkin(WrappedGameProfile profile, String skinOwner) {
		try {
			JSONObject json = (JSONObject) new JSONParser().parse((String) this.profileCache.get(skinOwner));
			JSONArray properties = (JSONArray) json.get("properties");
			for (int i = 0; i < properties.size(); i++) {
				JSONObject property = (JSONObject) properties.get(i);
				String name = (String) property.get("name");
				String value = (String) property.get("value");
				String signature = (String) property.get("signature");

				((GameProfile) profile.getHandle()).getProperties().put(name, new Property(name, value, signature));
			}
		} catch (Exception e) {
			throw new RuntimeException("Cannot fetch profile for " + skinOwner, e);
		}
	}

	public void changeDisplay(String string, String toSkin) {
		changeDisplay(string, toSkin, null);
	}

	public void changeDisplay(Player player, String toSkin, String toName) {
		if ((updateMap(this.skinNames, player.getName(), toSkin) | updateMap(this.displayNames, player.getName(), toName))) {
			refreshPlayer(player);
		}
	}

	public void changeDisplay(String playerName, String toSkin, String toName) {
		if ((updateMap(this.skinNames, playerName, toSkin) | updateMap(this.displayNames, playerName, toName))) {
			refreshPlayer(playerName);
		}
	}

	public void removeChanges(Player player) {
		changeDisplay(player.getName(), null, null);
	}

	public void removeChanges(String playerName) {
		changeDisplay(playerName, null, null);
	}

	private <T, U> boolean updateMap(Map<T, U> map, T key, U value) {
		if (value == null) {
			return map.remove(key) != null;
		}
		return !Objects.equal(value, map.put(key, value));
	}

	private void refreshPlayer(String name) {
		Player player = Bukkit.getPlayer(name);
		if (player != null) {
			refreshPlayer(player);
		}
	}

	private void refreshPlayer(Player player) {
		this.protocolManager.updateEntity(player, this.protocolManager.getEntityTrackers(player));
	}
}
public class SkinCommand implements CommandExecutor {
	Main plugin;
	private SkinChangeManager factory;

	public SkinCommand(Main plugin) {
		this.plugin = plugin;
		this.plugin.getCommand("skin").setExecutor(this);
	}

	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		if (args.length == 1) {
			if (!(sender instanceof Player)) {
				sender.sendMessage("§cPoprawne uzycie: §6/skin <gracz> <skinGracza>");
				return true;
			}
			Player p = (Player) sender;
			this.factory = new SkinChangeManager(this.plugin);
			this.factory.changeDisplay(p.getName(), "MrTrolekk", args[0]);
			sender.sendMessage("§aMasz teraz skin gracza §e" + args[0]);
		} else if (args.length == 2) {
			if (!sender.hasPermission("tirex.skin.other")) {
				sender.sendMessage("§cPoprawne uzycie: §6/skin <skinGracza>");
				return true;
			}
			Player other = Bukkit.getPlayerExact(args[0]);
			if (other == null) {
				sender.sendMessage("§cTen Gracz nie jest Online!");
				return true;
			}
			this.factory = new SkinChangeManager(this.plugin);
			this.factory.changeDisplay("dada", "Dinnerbone", "Any name here");
			sender.sendMessage("§aUstawiles skin gracza §e" + args[1] + " §adla §e" + other.getName());
		} else if (!(sender instanceof Player)) {
			sender.sendMessage("§cPoprawne uzycie: §6/skin <gracz> <skinGracza>");
		} else {
			sender.sendMessage("§cPoprawne uzycie: §6/skin <skinGracza>");
		}
		return false;
	}
}

ech....

 

 

 

 

Opublikowano

public class SkinChangeManager {
	private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
	private static final int WORKER_THREADS = 4;
	private ProtocolManager protocolManager;
	private ConcurrentMap<String, String> skinNames = Maps.newConcurrentMap();
	private ConcurrentMap<String, String> displayNames = Maps.newConcurrentMap();
	private Cache<String, String> profileCache = CacheBuilder.newBuilder().maximumSize(500).expireAfterWrite(4L, TimeUnit.HOURS).build(new CacheLoader() {
		public String load(String name) throws Exception {
			return SkinChangeManager.this.getProfileJson(name);
		}
	});

	public SkinChangeManager(Plugin plugin) {
		this.protocolManager = ProtocolLibrary.getProtocolManager();
		this.protocolManager.getAsynchronousManager().registerAsyncHandler(new PacketAdapter(plugin, ListenerPriority.NORMAL, new PacketType[] {

		PacketType.Play.Server.NAMED_ENTITY_SPAWN,

		PacketType.Play.Server.ENTITY_EFFECT, PacketType.Play.Server.ENTITY_EQUIPMENT, PacketType.Play.Server.ENTITY_METADATA, PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ATTACH_ENTITY, PacketType.Play.Server.BED }) {
			public void onPacketSending(PacketEvent event) {
				if (event.getPacketType() != PacketType.Play.Server.NAMED_ENTITY_SPAWN) {
					return;
				}
				Player toDisplay = (Player) event.getPacket().getEntityModifier(event).read(0);
				String skinName = (String) SkinChangeManager.this.skinNames.get(toDisplay.getName());
				String displayName = (String) SkinChangeManager.this.displayNames.get(toDisplay.getName());
				if ((skinName == null) && (displayName == null)) {
					return;
				}
				StructureModifier<WrappedGameProfile> profiles = event.getPacket().getGameProfiles();
				WrappedGameProfile original = (WrappedGameProfile) profiles.read(0);
				WrappedGameProfile result = new WrappedGameProfile(SkinChangeManager.this.extractUUID(original.getName()), displayName != null ? displayName : original.getName());

				SkinChangeManager.this.updateSkin(result, skinName != null ? skinName : result.getName());
				profiles.write(0, result);
			}
		}).start(4);
	}

	private UUID extractUUID(String playerName) {
		return Bukkit.getOfflinePlayer(playerName).getUniqueId();
	}

	private String getProfileJson(String name) throws IOException {
		URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + extractUUID(name).toString().replace("-", ""));
		final URLConnection uc = url.openConnection();

		CharStreams.toString(new InputSupplier() {
			public InputStreamReader getInput() throws IOException {
				return new InputStreamReader(uc.getInputStream(), Charsets.UTF_8);
			}
		});
	}

	private void updateSkin(WrappedGameProfile profile, String skinOwner) {
		try {
			JSONObject json = (JSONObject) new JSONParser().parse((String) this.profileCache.get(skinOwner));
			JSONArray properties = (JSONArray) json.get("properties");
			for (int i = 0; i < properties.size(); i++) {
				JSONObject property = (JSONObject) properties.get(i);
				String name = (String) property.get("name");
				String value = (String) property.get("value");
				String signature = (String) property.get("signature");

				((GameProfile) profile.getHandle()).getProperties().put(name, new Property(name, value, signature));
			}
		} catch (Exception e) {
			throw new RuntimeException("Cannot fetch profile for " + skinOwner, e);
		}
	}

	public void changeDisplay(String string, String toSkin) {
		changeDisplay(string, toSkin, null);
	}

	public void changeDisplay(Player player, String toSkin, String toName) {
		if ((updateMap(this.skinNames, player.getName(), toSkin) | updateMap(this.displayNames, player.getName(), toName))) {
			refreshPlayer(player);
		}
	}

	public void changeDisplay(String playerName, String toSkin, String toName) {
		if ((updateMap(this.skinNames, playerName, toSkin) | updateMap(this.displayNames, playerName, toName))) {
			refreshPlayer(playerName);
		}
	}

	public void removeChanges(Player player) {
		changeDisplay(player.getName(), null, null);
	}

	public void removeChanges(String playerName) {
		changeDisplay(playerName, null, null);
	}

	private <T, U> boolean updateMap(Map<T, U> map, T key, U value) {
		if (value == null) {
			return map.remove(key) != null;
		}
		return !Objects.equal(value, map.put(key, value));
	}

	private void refreshPlayer(String name) {
		Player player = Bukkit.getPlayer(name);
		if (player != null) {
			refreshPlayer(player);
		}
	}

	private void refreshPlayer(Player player) {
		this.protocolManager.updateEntity(player, this.protocolManager.getEntityTrackers(player));
	}
}
public class SkinCommand implements CommandExecutor {
	Main plugin;
	private SkinChangeManager factory;

	public SkinCommand(Main plugin) {
		this.plugin = plugin;
		this.plugin.getCommand("skin").setExecutor(this);
	}

	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		if (args.length == 1) {
			if (!(sender instanceof Player)) {
				sender.sendMessage("§cPoprawne uzycie: §6/skin <gracz> <skinGracza>");
				return true;
			}
			Player p = (Player) sender;
			this.factory = new SkinChangeManager(this.plugin);
			this.factory.changeDisplay(p.getName(), "MrTrolekk", args[0]);
			sender.sendMessage("§aMasz teraz skin gracza §e" + args[0]);
		} else if (args.length == 2) {
			if (!sender.hasPermission("tirex.skin.other")) {
				sender.sendMessage("§cPoprawne uzycie: §6/skin <skinGracza>");
				return true;
			}
			Player other = Bukkit.getPlayerExact(args[0]);
			if (other == null) {
				sender.sendMessage("§cTen Gracz nie jest Online!");
				return true;
			}
			this.factory = new SkinChangeManager(this.plugin);
			this.factory.changeDisplay("dada", "Dinnerbone", "Any name here");
			sender.sendMessage("§aUstawiles skin gracza §e" + args[1] + " §adla §e" + other.getName());
		} else if (!(sender instanceof Player)) {
			sender.sendMessage("§cPoprawne uzycie: §6/skin <gracz> <skinGracza>");
		} else {
			sender.sendMessage("§cPoprawne uzycie: §6/skin <skinGracza>");
		}
		return false;
	}
}

ech....

 

 

 

 

Co to qrwa jest?¿?

Opublikowano

To nie jest skrypt tylko kod pluginu...

Wypromuje twój serwer minecraft na mclista :)

* 1000 diamentów w niecałe 24h,

* Twoj serwer znajdzie sie na 1 stronie,

* Po wiecej informacji zapraszam na PW,

¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

Opublikowano

chcial byc fajny i wstawil kod tirexa

Bardzo śmieszne... kod, zresztą jak każdy kod co robi coś ciekawego, należy do "aadnk" a.k.a. "Comphenix".

Ta tirexa.... żeś dowalił.

+ można też pobrać gotowy plugin:

http://dev.bukkit.org/bukkit-plugins/player-skin-changer/

To już jest koniec smerfa:


http://www.mpcforum.pl/topic/1323530-info-znikam/


GG: 48522543


PS: Na innych forach i stronach znajdziesz mnie pod nickiem: 


BukkitSmerf

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...